#pragma once

#include "templatevectorlist.h"

class Action;

class UndoManager
{
protected:
	TemplateVectorList<Action*> m_stack;
	int m_index;
public:
	UndoManager():m_stack(100),m_index(0){}

	int getCurrentIndex()
	{
		return m_index-1;
	}

	bool undo();
	bool redo();

	int getStackSize()
	{
		return m_stack.size();
	}

	Action * getAction(const int & a_index)
	{
		return (a_index >= 0)?m_stack.get(a_index):0;
	}

	Action * getCurrentAction()
	{
		return getAction(getCurrentIndex());
	}

	void addAction(Action & a_action);

	void addAction(Action & a_action, const bool & a_doAction);

	void release();

	~UndoManager(){release();}
};